import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout'

Vue.use(VueRouter)

/* Layout */

/**
 * state: 'hidden' || 'jump'
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/

export const constantRouterMap = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    state: 'hidden'
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    state: 'hidden'
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    state: 'hidden'
  },

  {
    path: '',
    // alias: ['/'],
    component: Layout,
    // state: 'hidden', //hidden、jump
    redirect: 'dashboard',
    name: 'Dashboard',
    // meta: { title: '首页' },
    roles: ['business_data'],
    children: [
      {
        path: '/dashboard',
        meta: {
          title: '首页',
          icon: 'home'
        },
        component: () => import('@/views/dashboard/index')
      }
    ]
  },
  {
    path: '/orders',
    component: Layout,
    // state: 'jump',
    name: 'orders',
    roles: ['order', 'order_manage', 'refund_operation'],
    meta: {
      title: '订单管理'
    },
    children: [
      {
        path: 'index',
        name: 'index',
        component: () => import('@/views/orders/index'),
        roles: ['order_manage'],
        meta: {
          title: '灰兔订单',
          icon: 'huitudingdan'
        }
      }
    ]
  },
  {
    path: '/device',
    component: Layout,
    // state: 'jump',
    name: 'device',
    roles: ['device_manage'],
    meta: {
      title: '设备管理'
    },
    children: [
      {
        path: 'cabinets',
        name: 'cabinets',
        component: () => import('@/views/cabinets/index'),
        meta: {
          title: '机柜管理',
          icon: 'jigui'
        }
      },
      {
        path: 'device',
        name: 'device',
        component: () => import('@/views/device/index'),
        meta: {
          title: '讲解器管理',
          icon: 'jiangjieqi'
        }
      }
    ]
  },
  {
    path: '/attraction',
    component: Layout,
    // state: 'jump',
    name: 'attraction',
    meta: {
      title: '景点管理'
    },
    children: [
      {
        path: '',
        name: 'scenic',
        component: () => import('@/views/attraction/index'),
        meta: {
          title: '景点管理',
          icon: 'jingdian'
        }
      },
      {
        path: 'voiceDirs',
        name: 'voiceDirs',
        component: () => import('@/views/attraction/voiceDirs'),
        meta: {
          title: '语音详情',
          activeMenu: '/attraction/'
        },
        hidden: true
      },
      {
        path: 'uploadList',
        name: 'uploadList',
        component: () => import('@/views/attraction/uploadList'),
        meta: {
          title: '导入列表',
          activeMenu: '/attraction/'
        },
        hidden: true
      },
      {
        path: 'dataList',
        name: 'dataList',
        component: () => import('@/views/attraction/dataList'),
        meta: {
          title: '景点数据',
          activeMenu: '/attraction/'
        },
        hidden: true
      },
      {
        path: 'fileList',
        name: 'fileList',
        component: () => import('@/views/attraction/fileList'),
        meta: {
          title: '语音详情',
          activeMenu: '/attraction/'
        },
        hidden: true
      }
    ]
  },
  {
    path: '/accountManage',
    component: Layout,
    // state: 'jump',
    roles: ['my_info', 'account_manage', 'role_manage'],
    name: 'accountManage',
    meta: {
      title: '账户管理'
    },
    children: [
      {
        path: 'account',
        name: 'account',
        roles: ['account_manage'],
        component: () => import('@/views/account/index'),
        meta: {
          title: '账号管理',
          icon: 'zhanghao'
        }
      },
      {
        path: 'roles',
        name: 'roles',
        component: () => import('@/views/roles/index'),
        roles: ['role_manage'],
        meta: {
          title: '角色管理',
          icon: 'juese'
        }
      }
    ]
  },
  {
    path: '/financial',
    component: Layout,
    // state: 'jump',
    roles: ['my_info', 'invoice_review'],
    name: 'financial',
    meta: {
      title: '财务管理'
    },
    children: [
      {
        path: 'invoice',
        name: 'invoice',
        roles: ['invoice_review'],
        component: () => import('@/views/invoice/index'),
        meta: {
          title: '开票管理',
          icon: 'kaipiao'
        }
      }
    ]
  },
  // {
  //   path: '/products',
  //   component: Layout,
  //   state: 'jump',
  //   name: 'products',
  //   meta: {
  //     title: '产品管理'
  //   },
  //   children: [
  //     {
  //       path: '',
  //       name: 'products',
  //       component: () => import('@/views/products/index'),
  //       meta: {
  //         title: '产品管理',
  //         icon: 'chanpinguanli'
  //       }
  //     }
  //   ]
  // },

  // {
  //   path: '/guides',
  //   component: Layout,
  //   state: 'jump',
  //   name: 'guides',
  //   meta: {
  //     title: '导游管理'
  //   },
  //   children: [
  //     {
  //       path: '',
  //       name: 'proguidesjects',
  //       component: () => import('@/views/guides/index'),
  //       meta: {
  //         title: '导游管理',
  //         icon: 'kehuqunzu'
  //       }
  //     }
  //   ]
  // },
  // {
  //   path: '/tickets',
  //   component: Layout,
  //   // state: 'jump',
  //   name: 'tickets',
  //   meta: {
  //     title: '门票管理',
  //     icon: 'guanliwenzhang'
  //   },
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'index',
  //       component: () => import('@/views/preTicket/index'),
  //       meta: {
  //         title: '门票列表'
  //       }
  //     },
  //     {
  //       path: 'idCards',
  //       name: 'idCards',
  //       component: () => import('@/views/idCards/index'),
  //       meta: {
  //         title: '身份证列表'
  //       }
  //     }
  //   ]
  // },
  // {
  //   path: '/finance',
  //   component: Layout,
  //   state: 'jump',
  //   name: 'finance',
  //   meta: {
  //     title: '财务'
  //   },
  //   children: [
  //     {
  //       path: '',
  //       name: 'finance',
  //       component: () => import('@/views/finance/index'),
  //       meta: {
  //         title: '财务',
  //         icon: 'jianzhan'
  //       }
  //     }
  //   ]
  // },

  {
    path: '*',
    redirect: '/404',
    state: 'hidden'
  }
]

export default new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})
